<?php echo $this->Html->script('Suporte'); ?>
<div id="msg"></div>
<form action="/siscel/suporte/registrar/<?php echo $id ?>" id="SUPORTERegistrarForm" method="post" enctype="multipart/form-data">
    <input type="hidden" id="id" value="<?php echo $id ?>"/>
    <fieldset>
        <legend>Suporte</legend>
        <input type="hidden" name="_method" value="POST"/>
        <table width="98%" border="0" cellspacing="0" cellpadding="2">
            <thead>
                <th colspan="4" style="text-align: right;">
                    <b></b>
                    <?php
                    if(count($arrDialog) == 0){
                        echo $this->Html->image('/img/bt_apagar.gif', array('width' => '20', 'heigth' => '20', 'label' => null, 'onclick'=>'Suporte.excluirOS('.$arrOS[0]['Suporte']['CO_OS'].');' ));
                    }
                    switch ($arrOS[0]['Suporte']['ST_OS'])
                    {
                        case "A"://ABERTA
                            echo $this->Html->image('/img/bullet_green.png', array('width' => '20', 'heigth' => '20', 'label' => null, 'title'=>'Aberta' ));
                            break;
                        case "M"://EM FECHAMENTO
                            echo $this->Html->image('/img/bullet_orange.png', array('width' => '20', 'heigth' => '20', 'label' => null, 'title'=>'Em Fechamento' ));
                            break;
                        case "F"://FECHADA
                            echo $this->Html->image('/img/bullet_black.png', array('width' => '20', 'heigth' => '20', 'label' => null, 'title'=>'Fechada' ));
                            break;
                        case "I"://EXCLUIDA
                            echo $this->Html->image('/img/bullet_delete.png', array('width' => '20', 'heigth' => '20', 'label' => null, 'title'=>'Excluída' ));
                            break;
                    }
                    ?>
                </th>
            </thead>
            <tr>
                <td>
                    <?php echo $this->Form->input('NR_OS', array('type' => 'text', 'label' => 'TKT', 'id' => 'nrOS', 'class' => 'campoAlfa', 'size' => "20", 'maxlength' => "15", "readonly"=>"readonly", "value" => $arrOS[0][0]['NR_OS'].' - '.$arrOS[0]['Suporte']['DS_TITULO_OS'] )); ?>
                </td>
                <td>
                    <?php echo $this->Form->input('DT_ABERTURA', array('type' => 'text', 'label' => 'Data', 'id' => 'txtTitulo', 'size' => "20", 'maxlength' => "15", "readonly"=>"readonly", "value" => date('d/m/Y H:i', strtotime($arrOS[0]['Suporte']['DT_ABERTURA']))  )); ?>
                </td>
            </tr>
            <tr>
                <td>
                    <?php echo $this->Form->input('NM_AUT', array('type' => 'text', 'label' => 'Usuário', 'id' => 'txtUsuario', 'class' => 'campoAlfa', "readonly"=>"readonly", 'value'=>$arrOS[0]['Usuario']['NM_AUT'] )); ?>
                </td>
                <td>
                    <?php echo $this->Form->input('NM_INST_CURTO', array('type' => 'text', 'label' => 'Unidade', 'id' => 'txtNomeCurto', 'class' => 'campoAlfa', "readonly"=>"readonly", 'value' => $arrOS[0]['InstituicaoLab']['NM_INST_CURTO'] )); ?>
                </td>
            </tr>
            <tr>
                <td>
                    <?php echo $this->Form->input('CO_PERFIL', array('type' => 'text', 'label' => 'Perfil', 'id' => 'cdPerfil', "readonly"=>"readonly", 'value' => $arrOS[0]['Perfil']['NO_PERFIL'] )); ?>
                </td>
                <td>
                    <?php echo $this->Form->input('Interacao.CO_OS', array('type' => 'hidden', 'id' => 'coOS', 'value' => $arrOS[0]['Suporte']['CO_OS'] )); ?>
                </td>
            </tr>
        </table>
        <div style="height: 250px;overflow: auto;">
            <table width="98%" border="0" cellspacing="0" cellpadding="2">
                <thead>
                    <th colspan="3">
                        <b>DIÁLOGO</b>
                    </th>
                </thead>
                <?php
                if(is_array($arrDialog)){
                    foreach($arrDialog as $v){ ?>
                    <tr>
                        <td style="width: 15%;">
                            <?php echo date('d/m/Y H:i', strtotime($v['Interacao']['DT_INTERACAO']))  ?><br/>
                            <?php echo $v['Usuario']['NM_AUT'] ?>
                        </td>
                        <td style="width: 80%;"><?php echo $v['Interacao']['TX_INTERACAO'] ?></td>
                        <td style="width: 5%;">
                            <?php
                                if($v[0]['TOTAL_ANEXOS'] > 0 ){
                                    echo $this->Html->image('/img/anexos.gif', array('width' => '16', 'heigth' => '16', 'label' => null, 'onclick'=>'Suporte.exibirAnexos('.$v['Interacao']['CO_INTERACAO'].')' ));
                                }
                            ?>
                        </td>
                    </tr>
                <?php }
                } ?>
            </table>
        </div>
        <table width="98%" border="0" cellspacing="0" cellpadding="2">
            <tr>
                <td colspan="2" style="width: 70%;">
                    <?php echo $this->Form->input('Interacao.TX_INTERACAO', array('type' => 'textarea', 'label' => 'Mensagem', 'id' => 'txtInteracao' )); ?>
                </td>
                <td>
                    <div style="height: 120px;overflow: auto;">
                        <input type="file" name="arquivos[]" id="arquivos" class="multi-pt"/>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div class="button" style="float: left; clear: right;">
                        <input  type="button" value="Fechar Tiquete" id="btRegistrarMedico" style="width:110px;"/>
                    </div>
                    <div class="submit" style="float: right; clear: right;">
                        <input id="btRegistrarMedico" type="submit" value="Postar"/>
                    </div>
                </td>
            </tr>
        </table>        
    </fieldset>
</form>
<div id="dialog"></div>
<script type="text/javascript">
    $(document).ready(function(){
        Suporte.init();
        $('#btRegistrarMedico').click(function(){
            $('#SUPORTERegistrarForm').attr('action','/siscel/suporte/fecharos/'+$('#id').val()).submit();
        });
    });
</script>